<?php 
	session_start();
	if(isset($_SESSION['issess']) && $_SESSION['issess']!='')
	{
	?>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>AP Forest Department R &amp; D Circle</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="description" content="">
		<meta name="author" content="">
		<!-- Le styles -->
		<link href='http://fonts.googleapis.com/css?family=Monda' rel='stylesheet' type='text/css'>
		<link href="css/style.css" rel="stylesheet">
		<link href="css/aptable-responsive.css" rel="stylesheet">		
		<script src="js/jquery.min.js"></script>
	</head>
		<body style="background:#f5f5f5">
			<?php
			ini_set('display_errors', '0');
			include("connect.php");
			if(count($_POST)){
				if(mysql_query("update user set password='".md5($_POST['password'])."' where email_id='".$admin_email."'")){
					header("location:admin-page.php");
				}
			}
			?>
			<div style="background:#f5f5f5">
				<div class="wrapper">
					<div class="logo mar_top">
						<img src="images/apfd-Logo.png"/>
					</div>	
					<div >
						<div class="span4">
							<form class="login" id="changepwd_form" name="changepwd_form" method="POST" action="" >
							<h1>Change Password</h1>
							<div class="inputs ">
								<input class="password span3" id="password" name="password" type="password" placeholder="New Password" autofocus required>   
								<input class="password span3" id="cnf_password" name="cnf_password" type="password" placeholder="Confirm Password" required> 
							</div>
							<div id="actions">
								<a onClick="savePassword();" class="submit" href="javascript:void(0)">Save</a>
							</div>
							<div class="clear val_red_col"></div>
								<div id="newPasswordSpan" class="val_red_col" ></div>
								<div id="confirmPasswordSpan" class="val_red_col" ></div>
							</form>
						</div>
					</div>
					
				</div>
			</div>
		</body>
	<script type="text/javascript">
	function savePassword()
	{
		$('.clear').html('');
		var password = $("#password").val().trim();;
		var cnf_password = $("#cnf_password").val().trim();

		if( password == "" )
		{
		$('#newPasswordSpan').html('*Please enter new password');
			$("#password").focus();
			return false;
		}else{
			$('#newPasswordSpan').html('');
		}
		if( cnf_password == "" )
		{
			$('#confirmPasswordSpan').html('*Please enter confirm password');
			$("#cnf_password").focus();
			return false;
		}else{
			$('#confirmPasswordSpan').html('');
		}

		if( password != cnf_password )
		{
			$('.clear').html('*Please enter password and confirm password as same');
			$("#password").focus();
			return false;
		}
		else{
		$("#changepwd_form").submit();
		}
	}
	</script>
</html>
<?php }else{ header("location:admin-page.php");}?>
